import http from "@/api/config/http";
import { IQuery, IResponse } from "@/interface/IAxios";

export interface ResolutionModal {
  id?: number;
  color: string;
  scale: number;
  dpi: number;
  flip: "0" | "1";
  description: string;
  resolutionId: string;
  width: number;
  height: number;
  createTime: string;
  updateTime: string;
  resolutionDesc: string;
}

export const modelList = (query: IQuery) => {
  return http.request({
    url: `/resolution/type/list`,
    method: "get",
    params: query
  });
};

export const queryModel = (
  type: "lcd" | "all" | "esl" = "all"
): Promise<IResponse<ResolutionModal[]>> => {
  let params: any = {};
  if (type === "lcd") {
    params.queryType = "1";
  } else if (type === "esl") {
    params.queryType = "0";
  }
  return http.request({
    url: `/resolution/type/query`,
    method: "get",
    params
  });
};
export const modelDetail = (id: number | string) => {
  return http.request({
    url: `/resolution/type/${id}`,
    method: "get"
  });
};
export const updateModel = (data: ResolutionModal) => {
  return http.request({
    url: `/resolution/type`,
    method: "put",
    data
  });
};

export const createModal = (data: ResolutionModal) => {
  return http.request({
    url: `/resolution/type`,
    method: "post",
    data
  });
};

export const delModel = (id: (number | string)[]) => {
  return http.request({
    url: `/resolution/type/${id}`,
    method: "delete"
  });
};
